<template>
  <div>
    <el-card shadow="never" :body-style="{ padding: '10px' }">
      <!-- 卡片头部 -->
      <div slot="header">
        <!-- <el-button type="text" icon="el-icon-back" @click="goBack"
          >返回</el-button
        > -->
        <el-divider direction="vertical"></el-divider>
        学员姓名：<span class="head-font">{{ studentName }}</span>
        <el-divider direction="vertical"></el-divider>
        记录总数：<span class="head-font">{{ totalNum }}</span>
      </div>
      <!-- 卡片信息 -->
      <div style="float: left; width: 100%">
        <!-- 信息列表 -->
        <el-table
          border
          v-loading="listLoading"
          :header-cell-style="{ background: '#FAFAFA' }"
          :data="recordList"
          height="780px"
          style="width: 100%"
        >
          <el-table-column type="index" width="100"> </el-table-column>
          <el-table-column prop="eduTestRecordInfo.studentId" label="学员id">
          </el-table-column>
          <el-table-column prop="eduTestRecordInfo.testId" label="试卷id">
          </el-table-column>
          <el-table-column prop="title" label="试卷名"> </el-table-column>
          <el-table-column prop="eduTestRecordInfo.finalScore" label="分数">
          </el-table-column>

          <el-table-column prop="gmtCreate" label="记录时间"> </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>
<script>
import { getRecordsByTestId, getRecordsByStudentId } from "@/api/testRecord";
export default {
  //做题记录列表
  name: "studentStudyRecord",
  data: function () {
    return {
      //表格加载遮罩
      listLoading: "false",
      //学员编号
      studentId: this.$route.query.id,
      //学员姓名
      studentName: this.$route.query.studentName,
      //记录总数
      totalNum: "",
      //记录列表
      recordList: [],
    };
  },
  created: function () {
    this.queryAllRecord();
  },
  methods: {
    //根据学员编号查找的学习记录列表
    queryAllRecord() {
      this.listLoading = true;
      getRecordsByStudentId(this.studentId).then((res) => {
        const data = res.data;
        this.totalNum = data.total;
        this.recordList = data.resList;
        // this.recordList.forEach(function (item) {
        //   item.studentName = data.studentName;
        // });
        this.listLoading = false;
      });
    },
    //返回
    goBack() {
      this.$router.push({
        name: "List",
      });
    },
  },
};
</script>
<style scoped>
.head-font {
  font-weight: bold;
}
.search {
  width: 30%;
}
.el-card {
  height: 100vh;
}
</style>